<?php

class FormChangePassword extends User {

    public $config = array();
    public $password_repeat;

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public function init() {
        $this->config = array(
            'class' => 'form',
            'action' => '/user/settings#tab2',
            'activeForm' => array(
                'class' => 'CActiveForm',
                'enableAjaxValidation' => true,
                'enableClientValidation' => true,
                'id' => 'password-form',
            ),
            'elements' => array(
                'password' => array('type' => 'password', 'value' => ''),
                'password_repeat' => array('type' => 'password', 'value' => ''),
            ),
            'buttons' => array(
                'send_new_password' => array('type' => 'htmlSubmit', 'value' => 1, 'class' => 'blue', 'label' => '<span class="label">Сохранить</span>'),
            )
        );
        return parent::init();
    }

    public function rules() {
        return array(
            array('password, password_repeat', 'required'),
            array('password', 'length', 'max' => 128, 'min' => 6),
            array('password_repeat', 'compare', 'compareAttribute' => 'password'),);
    }

    public function attributeLabels() {
        return array(
            'password' => 'Пароль',
            'password_repeat' => "Повторите пароль",
        );
    }
}
